python中输入else报错是什么原因 您所在的位置:网站首页 python else不输出 python中输入else报错是什么原因

python中输入else报错是什么原因

2024-07-14 14:00| 来源: 网络整理| 查看: 265

python中输入else报错是什么原因

头像

silencement

2020-01-04 10:40:207338浏览 · 0收藏 · 0评论

if的用法

1.只有 if 进行判断

desserts = ['ice cream', 'chocolate', 'apple crisp', 'cookies'] favorite_dessert = 'apple crisp' hate_dessert = 'chocolate' for dessert in desserts:     if dessert == favorite_dessert:         print("%s is my favorite dessert!" % dessert.title())

2. if - else 进行判断

for dessert in desserts:     # 比较运算符(== 相等 、!= 不等、> 大于、>= 大于等于、 大于、>= 大于等于、 分享

分享到微博

微信扫一扫

下一篇: python还要装什么软件>



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有